home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK1.toast / Development Kits (Disc 1) / PC Card Manager / CIncludes / Kernel.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-11-25  |  28.2 KB  |  876 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        Kernel.h
  3.  
  4.      Contains:    Kernel Interfaces
  5.  
  6.      Version:    System 8
  7.  
  8.      DRI:        Russell Williams
  9.  
  10.      Copyright:    © 1984-1996 by Apple Computer, Inc.
  11.                  All rights reserved.
  12.  
  13.      Warning:    *** APPLE INTERNAL USE ONLY ***
  14.                  This file may contain unreleased API's
  15.  
  16.      BuildInfo:    Built by:            SuperMario Build Daemon
  17.                  With Interfacer:    2.0d11   (PowerPC native)
  18.                  From:                Kernel.i
  19.                      Revision:        93
  20.                      Dated:            3/8/96
  21.                      Last change by:    DFH
  22.                      Last comment:    Move PageAttributes from Kernel.i to
  23.  
  24.      Bugs:        Report bugs to Radar component “System Interfaces”, “Latest”
  25.                  List the version information (from above) in the Problem Description.
  26.  
  27. */
  28. #ifndef __KERNEL__
  29. #define __KERNEL__
  30.  
  31. #ifndef __ERRORS__
  32. #include <Errors.h>
  33. #endif
  34. #ifndef __MACHINEEXCEPTIONS__
  35. #include <MachineExceptions.h>
  36. #endif
  37. #ifndef __TIMING__
  38. #include <Timing.h>
  39. #endif
  40. #ifndef __TYPES__
  41. #include <Types.h>
  42. #endif
  43.  
  44. #ifdef __cplusplus
  45. extern "C" {
  46. #endif
  47.  
  48. #if PRAGMA_IMPORT_SUPPORTED
  49. #pragma import on
  50. #endif
  51.  
  52. #if PRAGMA_ALIGN_SUPPORTED
  53. #pragma options align=power
  54. /* the following contents can only be used by compilers that support PowerPC struct alignment */
  55.  
  56. #if FOR_SYSTEM7_AND_SYSTEM8_PREEMPTIVE
  57. /* Kernel basics*/
  58. typedef struct OpaqueAddressSpaceID* AddressSpaceID;
  59. typedef struct OpaqueIOPreparationID* IOPreparationID;
  60. typedef struct OpaqueSoftwareInterruptID* SoftwareInterruptID;
  61. typedef struct OpaqueTaskID* TaskID;
  62. typedef struct OpaqueTimerID* TimerID;
  63. /* Tasking*/
  64. typedef UInt32 ExecutionLevel;
  65.  
  66. enum {
  67.     kTaskLevel                    = 0,
  68.     kSoftwareInterruptLevel        = 1,
  69.     kAcceptFunctionLevel        = 2,
  70.     kKernelLevel                = 3,
  71.     kSIHAcceptFunctionLevel        = 4,
  72.     kSecondaryInterruptLevel    = 5,
  73.     kHardwareInterruptLevel        = 6
  74. };
  75.  
  76. typedef void (*SoftwareInterruptHandler)(void *p1, void *p2);
  77. typedef OSStatus (*SecondaryInterruptHandler2)(void *p1, void *p2);
  78. /* Memory System basics*/
  79. struct LogicalAddressRange {
  80.     LogicalAddress                     address;
  81.     ByteCount                         count;
  82. };
  83. typedef struct LogicalAddressRange LogicalAddressRange;
  84.  
  85. typedef LogicalAddressRange *LogicalAddressRangePtr;
  86. struct PhysicalAddressRange {
  87.     PhysicalAddress                 address;
  88.     ByteCount                         count;
  89. };
  90. typedef struct PhysicalAddressRange PhysicalAddressRange;
  91.  
  92. typedef PhysicalAddressRange *PhysicalAddressRangePtr;
  93. /* For PrepareMemoryForIO and CheckpointIO*/
  94. typedef OptionBits IOPreparationOptions;
  95.  
  96. enum {
  97.     kIOMultipleRanges            = 0x00000001,
  98.     kIOLogicalRanges            = 0x00000002,
  99.     kIOMinimalLogicalMapping    = 0x00000004,
  100.     kIOShareMappingTables        = 0x00000008,
  101.     kIOIsInput                    = 0x00000010,
  102.     kIOIsOutput                    = 0x00000020,
  103.     kIOCoherentDataPath            = 0x00000040,
  104.     kIOTransferIsLogical        = 0x00000080,
  105.     kIOClientIsUserMode            = 0x00000080
  106. };
  107.  
  108. typedef OptionBits IOPreparationState;
  109.  
  110. enum {
  111.     kIOStateDone                = 0x00000001
  112. };
  113.  
  114.  
  115. enum {
  116.     kInvalidPageAddress            = (-1)
  117. };
  118.  
  119. struct AddressRange {
  120.     void *                            base;
  121.     ByteCount                         length;
  122. };
  123. typedef struct AddressRange AddressRange;
  124.  
  125. /* C's treatment of arrays and array pointers is atypical*/
  126. typedef LogicalAddress *LogicalMappingTablePtr;
  127. typedef PhysicalAddress *PhysicalMappingTablePtr;
  128. typedef AddressRange *AddressRangeTablePtr;
  129. struct MultipleAddressRange {
  130.     ItemCount                         entryCount;
  131.     AddressRangeTablePtr             rangeTable;
  132. };
  133. typedef struct MultipleAddressRange MultipleAddressRange;
  134.  
  135. /*
  136.  Separate C definition so that union has a name.  A future version of the interfacer
  137.  tool will allow a name (that gets thrown out in Pascal and Asm).
  138. */
  139. struct IOPreparationTable {
  140.     IOPreparationOptions             options;
  141.     IOPreparationState                 state;
  142.     IOPreparationID                 preparationID;
  143.     AddressSpaceID                     addressSpace;
  144.     ByteCount                         granularity;
  145.     ByteCount                         firstPrepared;
  146.     ByteCount                         lengthPrepared;
  147.     ItemCount                         mappingEntryCount;
  148.     LogicalMappingTablePtr             logicalMapping;
  149.     PhysicalMappingTablePtr         physicalMapping;
  150.     union {
  151.         AddressRange                     range;
  152.         MultipleAddressRange             multipleRanges;
  153.     }                                 rangeInfo;
  154. };
  155. typedef struct IOPreparationTable IOPreparationTable;
  156.  
  157. typedef OptionBits IOCheckpointOptions;
  158.  
  159. enum {
  160.     kNextIOIsInput                = 0x00000001,
  161.     kNextIOIsOutput                = 0x00000002,
  162.     kMoreIOTransfers            = 0x00000004
  163. };
  164.  
  165. /* For SetProcessorCacheMode*/
  166. typedef UInt32 ProcessorCacheMode;
  167.  
  168. enum {
  169.     kProcessorCacheModeDefault    = 0,
  170.     kProcessorCacheModeInhibited = 1,
  171.     kProcessorCacheModeWriteThrough = 2,
  172.     kProcessorCacheModeCopyBack    = 3
  173. };
  174.  
  175. /* For GetPageInformation*/
  176.  
  177. enum {
  178.     kPageInformationVersion        = 1
  179. };
  180.  
  181. typedef UInt32 PageStateInformation;
  182.  
  183. enum {
  184.     kPageIsProtected            = 0x00000001,
  185.     kPageIsProtectedPrivileged    = 0x00000002,
  186.     kPageIsModified                = 0x00000004,
  187.     kPageIsReferenced            = 0x00000008,
  188.     kPageIsLockedResident        = 0x00000010,
  189.     kPageIsInMemory                = 0x00000020,
  190.     kPageIsShared                = 0x00000040,
  191.     kPageIsWriteThroughCached    = 0x00000080,
  192.     kPageIsCopyBackCached        = 0x00000100,
  193.     kPageIsLocked                = kPageIsLockedResident,        /* Deprecated*/
  194.     kPageIsResident                = kPageIsInMemory                /* Deprecated*/
  195. };
  196.  
  197. struct PageInformation {
  198.     AreaID                             area;
  199.     ItemCount                         count;
  200.     PageStateInformation             information[1];
  201. };
  202. typedef struct PageInformation PageInformation;
  203.  
  204. typedef PageInformation *PageInformationPtr;
  205. #endif
  206. #if FOR_SYSTEM8_PREEMPTIVE
  207. typedef struct OpaqueAreaReservationID* AreaReservationID;
  208. typedef struct OpaqueBackingObjectID* BackingObjectID;
  209. typedef struct OpaqueEventGroupID* EventGroupID;
  210. typedef struct OpaqueMessageID* MessageID;
  211. typedef struct OpaqueObjectID* ObjectID;
  212. typedef struct OpaquePortID* PortID;
  213. typedef struct OpaqueReceiveID* ReceiveID;
  214. typedef struct OpaqueKernelProcessID* KernelProcessID;
  215. typedef struct OpaqueKernelQueueID* KernelQueueID;
  216. /*  System Information  */
  217.  
  218. enum {
  219.     kSystemInformationVersion    = 1
  220. };
  221.  
  222. struct SystemInformation {
  223.     ItemCount                         numPhysicalRAMPages;
  224.     ItemCount                         numFreeRAMPages;
  225.     ItemCount                         numEligibleRAMPages;
  226.     ItemCount                         numResidentRAMPages;
  227.     ItemCount                         numInMemoryGlobalPages;
  228.     ItemCount                         numLogicalPages;
  229.     ByteCount                         pageSize;
  230.     ByteCount                         dataCacheBlockSize;
  231.     UInt32                             processorVersionNumber;
  232.     ItemCount                         numCPUs;
  233.     KernelProcessID                 systemKernelProcessID;
  234.     AddressSpaceID                     globalAddressSpaceID;
  235.     ByteCount                         dataCacheSize;
  236.     ByteCount                         instructionCacheSize;
  237.     Boolean                         cachesAreUnified;
  238.     SInt8                             filler[3];
  239. };
  240. typedef struct SystemInformation SystemInformation;
  241.  
  242. typedef SystemInformation *SystemInformationPtr;
  243. /*  KernelQueue Related Declarations  */
  244. typedef OptionBits KernelQueueOptions;
  245. /*  Event Flag Related Declarations  */
  246. typedef UInt32 EventGroupMask;
  247.  
  248. enum {
  249.     kEventFlagsPerGroup            = 32
  250. };
  251.  
  252. typedef UInt32 EventFlagOperation;
  253.  
  254. enum {
  255.     kEventFlagAll                = 0,
  256.     kEventFlagAny                = 1,
  257.     kEventFlagAllClear            = 2,
  258.     kEventFlagAnyClear            = 3,
  259.     kEventFlagSharedClear        = 4
  260. };
  261.  
  262. struct KernelNotification {
  263.     EventGroupID                     eventGroup;
  264.     EventGroupMask                     eventMask;
  265.     SoftwareInterruptID             swi;
  266.     KernelQueueID                     kernelQueue;
  267.     void *                            queueP1;
  268.     void *                            queueP2;
  269. };
  270. typedef struct KernelNotification KernelNotification;
  271.  
  272. typedef KernelNotification *KernelNotificationPtr;
  273. /*  Task Related Declarations  */
  274. typedef OSType KernelProcessName;
  275. typedef OSType TaskName;
  276. typedef OSStatus (*TaskProc)(void *parameter);
  277. typedef UInt32 TaskStorageIndex;
  278. typedef void *TaskStorageValue;
  279. typedef UInt32 TaskRelationship;
  280.  
  281. enum {
  282.     kTaskOnly                    = 0,
  283.     kTaskAndChildren            = 1,
  284.     kTaskFamily                    = 2,
  285.     kTaskKernelProcess            = 3
  286. };
  287.  
  288. typedef OptionBits SetTaskPriorityOptions;
  289.  
  290. enum {
  291.     kTaskRaisePriorityBy        = 0x00000200,
  292.     kTaskLowerPriorityBy        = 0x00000400,
  293.     kTaskRaisePriorityToAtLeast    = 0x00000800,
  294.     kTaskLowerPriorityToAtMost    = 0x00001000
  295. };
  296.  
  297. typedef OptionBits TaskOptions;
  298.  
  299. enum {
  300.     kTaskIsOrphan                = 0x00400000,
  301.     kTaskIsResident                = 0x00004000
  302. };
  303.  
  304. /* Priorities are used by CreateTask, SetTaskPriority, and AcceptMessage. */
  305. typedef OptionBits TaskPriority;
  306.  
  307. enum {
  308.     kTaskPriorityMask            = 0x0000001F,
  309.     kTaskPriorityIsAbsolute        = 0x00000100,
  310.     kTaskPriorityIsSymbolic        = 0x00002000,
  311.     kTaskBackgroundPriority        = 0x00002001,                    /* Gets only otherwise idle time*/
  312.     kTaskAppCPUBoundPriority    = 0x00002002,                    /* For CPU bound tasks*/
  313.     kTaskAppNonUIPriority        = 0x00002003,                    /* For general secondary tasks*/
  314.     kTaskAppPriority            = 0x00002004,                    /* Primary tasks*/
  315.     kTaskUIHelperPriority        = 0x00002005,                    /* Toolbox helper tasks*/
  316.     kTaskLowServerPriority        = 0x00002006,                    /* System servers*/
  317.     kTaskServerPriority            = 0x00002007,                    /* System serverss*/
  318.     kTaskHighServerPriority        = 0x00002008,                    /* System servers*/
  319.     kTaskLowDriverPriority        = 0x00002009,                    /* IO Families & plug-ins*/
  320.     kTaskDriverPriority            = 0x0000200A,                    /* IO Families & plug-ins*/
  321.     kTaskHighDriverPriority        = 0x0000200B,                    /* IO Families & plug-ins*/
  322.     kTaskRealTimePriority1        = 0x0000200C,                    /* Lowest real time priority*/
  323.     kTaskRealTimePriority2        = 0x0000200D,
  324.     kTaskRealTimePriority3        = 0x0000200E,
  325.     kTaskRealTimePriority4        = 0x0000200F,
  326.     kTaskRealTimePriority5        = 0x00002010,
  327.     kTaskRealTimePriority6        = 0x00002011,
  328.     kTaskRealTimePriority7        = 0x00002012,
  329.     kTaskRealTimePriority8        = 0x00002013,
  330.     kTaskRealTimePriority9        = 0x00002014,
  331.     kTaskRealTimePriority10        = 0x00002015,
  332.     kTaskRealTimePriority11        = 0x00002016,
  333.     kTaskRealTimePriority12        = 0x00002017,
  334.     kTaskRealTimePriority13        = 0x00002018,
  335.     kTaskRealTimePriority14        = 0x00002019,
  336.     kTaskRealTimePriority15        = 0x0000201A,
  337.     kTaskRealTimePriority16        = 0x0000201B                    /* Highest real time priority*/
  338. };
  339.  
  340. typedef OptionBits TerminateOptions;
  341. typedef OSType SchedulerState;
  342.  
  343. enum {
  344.     kTaskInformationVersion        = 1
  345. };
  346.  
  347. struct TaskInformation {
  348.     TaskName                         name;
  349.     KernelProcessID                 owningKernelProcess;
  350.     TaskOptions                     options;                    /* Includes originally specified symbolic priority*/
  351.     TaskPriority                     priority;                    /* Absolute priority*/
  352.     SchedulerState                     taskState;
  353.     SchedulerState                     swiState;
  354.     Boolean                         isTerminating;
  355.     Boolean                         reserved2[3];
  356.     ItemCount                         softwareInterrupts;
  357.     LogicalAddress                     stackLimit;
  358.     ByteCount                         stackSize;
  359.     AbsoluteTime                     creationTime;
  360.     AbsoluteTime                     cpuTime;
  361.     void *                            reserved;
  362. };
  363. typedef struct TaskInformation TaskInformation;
  364.  
  365. typedef TaskInformation *TaskInformationPtr;
  366. typedef OptionBits KernelProcessOptions;
  367.  
  368. enum {
  369.     kKernelProcessIsPrivileged    = 0x00000001
  370. };
  371.  
  372.  
  373. enum {
  374.     kKernelProcessInformationVersion = 1
  375. };
  376.  
  377. struct KernelProcessInformation {
  378.     KernelProcessName                 name;
  379.     AddressSpaceID                     addressSpace;
  380.     KernelProcessOptions             options;
  381. };
  382. typedef struct KernelProcessInformation KernelProcessInformation;
  383.  
  384. typedef KernelProcessInformation *KernelProcessInformationPtr;
  385. /* Timer related declarations */
  386. typedef OptionBits TimerOptions;
  387. /*  Address Space Management related declarations  */
  388. /* General definitions*/
  389. #define kNoBackingObjectID    ((BackingObjectID) kInvalidID)
  390. typedef OptionBits AreaOptions;
  391.  
  392. enum {
  393.     kZeroFill                    = 0x00000001,
  394.     kResidentArea                = 0x00000002,
  395.     kSparseArea                    = 0x00000004,
  396.     kPlacedArea                    = 0x00000008,
  397.     kGlobalArea                    = 0x00000010,
  398.     kPhysicallyContiguousArea    = 0x00000020,
  399.     kMassMappedArea                = 0x00000040
  400. };
  401.  
  402. typedef OptionBits InterspaceCopyOptions;
  403.  
  404. enum {
  405.     kCheckSourceUserRights        = 0x00000001,
  406.     kCheckDestinationUserRights    = 0x00000002
  407. };
  408.  
  409. typedef UInt32 AreaUsage;
  410.  
  411. enum {
  412.     kUsageUnknown                = 0,
  413.     kUsageRAM                    = 1,
  414.     kUsageROM                    = 2,
  415.     kUsageIO                    = 3,
  416.     kUsageVideoRAM                = 4
  417. };
  418.  
  419. typedef UInt32 MemoryAccessLevel;
  420.  
  421. enum {
  422.     kMemoryExcluded                = 0,
  423.     kMemoryReadOnly                = 1,
  424.     kMemoryReadWrite            = 2,
  425.     kMemoryCopyOnWrite            = 3,
  426.     kInheritUserAccess            = 4,
  427.     kInheritPrivilegedAccess    = 5
  428. };
  429.  
  430. typedef UInt64 BackingAddress;
  431. typedef UInt64 BackingLength;
  432. /*    For GetSpaceInformation*/
  433.  
  434. enum {
  435.     kSpaceInformationVersion    = 1
  436. };
  437.  
  438. struct SpaceInformation {
  439.     ItemCount                         numLogicalPages;
  440.     ItemCount                         numInMemoryPages;
  441.     ItemCount                         numResidentPages;
  442. };
  443. typedef struct SpaceInformation SpaceInformation;
  444.  
  445. typedef SpaceInformation *SpaceInformationPtr;
  446. /*    For GetAreaInformation*/
  447.  
  448. enum {
  449.     kAreaInformationVersion        = 1
  450. };
  451.  
  452. struct AreaInformation {
  453.     AddressSpaceID                     addressSpace;
  454.     LogicalAddress                     base;
  455.     ByteCount                         length;
  456.     MemoryAccessLevel                 userAccessLevel;
  457.     MemoryAccessLevel                 privilegedAccessLevel;
  458.     AreaUsage                         usage;
  459.     BackingObjectID                 backingObject;
  460.     BackingAddress                     backingBase;
  461.     AreaOptions                     options;
  462.     KernelProcessID                 owningKernelProcess;
  463. };
  464. typedef struct AreaInformation AreaInformation;
  465.  
  466. typedef AreaInformation *AreaInformationPtr;
  467. /*    For Memory Reservations*/
  468. typedef OptionBits ReservationOptions;
  469.  
  470. enum {
  471.     kPlacedReservation            = 0x00000001,
  472.     kGlobalReservation            = 0x00000002,
  473.     kGlobalAreaReservation        = 0x00000004
  474. };
  475.  
  476. /*    For GetReservationInformation*/
  477.  
  478. enum {
  479.     kReservationInformationVersion = 1
  480. };
  481.  
  482. struct ReservationInformation {
  483.     AddressSpaceID                     addressSpace;
  484.     LogicalAddress                     base;
  485.     ByteCount                         length;
  486.     ReservationOptions                 options;
  487. };
  488. typedef struct ReservationInformation ReservationInformation;
  489.  
  490. typedef ReservationInformation *ReservationInformationPtr;
  491. /*    For ControlPagingForRange*/
  492. typedef UInt32 PageControlOperation;
  493.  
  494. enum {
  495.     kControlPageMakePageable    = 1,
  496.     kControlPageMakeResident    = 2,
  497.     kControlPageCommit            = 3,
  498.     kControlPageTouch            = 4,
  499.     kControlPageReplace            = 5,
  500.     kControlPageFlush            = 6,
  501.     kControlPageFlushAsync        = 7
  502. };
  503.  
  504. /* For ReleaseData*/
  505. typedef OptionBits ReleaseDataOptions;
  506.  
  507. enum {
  508.     kReleaseBackingStore        = 0x00000001
  509. };
  510.  
  511. /*  Message related declarations  */
  512. typedef UInt32 MessageType;
  513. /* Kernel Message Types*/
  514. #define kAllNonKernelMessageTypes    (SInt32)0x0FFFFFFF
  515. #define kAllMessages                (SInt32)0xFFFFFFFF
  516. /*    Options for CreatePort*/
  517. typedef OptionBits PortOptions;
  518. /*    Options for CreateObject*/
  519. typedef OptionBits ObjectOptions;
  520. /*    Options for LockObject*/
  521. typedef OptionBits ObjectLockOptions;
  522.  
  523. enum {
  524.     kLockObjectWithOneMessage    = 0x00000001
  525. };
  526.  
  527. /*    Options for SetObjectInformation;*/
  528. typedef OptionBits SetObjectOptions;
  529.  
  530. enum {
  531.     kSetObjectPort                = 0x00000002,
  532.     kSetObjectRefcon            = 0x00000004
  533. };
  534.  
  535. /*  Message System Options  */
  536. typedef OptionBits SendOptions;
  537.  
  538. enum {
  539.     kSendTransferKindMask        = 0x00000003,                    /* Set by sender*/
  540.     kSendByChoice                = 0x00000000,
  541.     kSendByReference            = 0x00000001,
  542.     kSendByValue                = 0x00000002,
  543.     kSendIsBuffered                = 0x00000003,
  544.     kSendIsPrivileged            = 0x00000008,                    /* Set by kernel*/
  545.     kSendIsAtomic                = 0x00000010,                    /* Set by sender*/
  546.     kSendPtrsAddressable        = 0x00000020,                    /* Set by kernel*/
  547.     kSendPtrsNeedAccessCheck    = 0x00000040                    /* Set by kernel*/
  548. };
  549.  
  550. typedef OptionBits ReceiveOptions;
  551.  
  552. enum {
  553.     kReceiveNoAddressTranslation = 0x00000002
  554. };
  555.  
  556. typedef OptionBits AcceptOptions;
  557.  
  558. enum {
  559.     kAcceptFunctionIsResident    = 0x00010000
  560. };
  561.  
  562. /*  Message Definition (Given to receiver or acceptor)  */
  563. struct MessageControlBlock {
  564.     MessageID                         message;
  565.     AddressSpaceID                     addressSpace;
  566.     KernelProcessID                 sendingKernelProcess;
  567.     TaskID                             sendingTask;
  568.     void *                            refcon;
  569.     SendOptions                     options;
  570.     MessageType                     theType;
  571.     LogicalAddress                     messageContents;
  572.     ByteCount                         messageContentsSize;
  573.     LogicalAddress                     replyBuffer;
  574.     ByteCount                         replyBufferSize;
  575.     OSStatus                         currentStatus;
  576.     UInt32                             reserved[4];
  577. };
  578. typedef struct MessageControlBlock MessageControlBlock;
  579.  
  580. typedef MessageControlBlock *MessageControlBlockPtr;
  581.  
  582. enum {
  583.     kMessageInformationVersion    = 1
  584. };
  585.  
  586. struct MessageInformation {
  587.     ObjectID                         object;
  588.     TaskID                             sendingTask;
  589.     KernelProcessID                 sendingKernelProcess;
  590. };
  591. typedef struct MessageInformation MessageInformation;
  592.  
  593. typedef MessageInformation *MessageInformationPtr;
  594. /*  Message Accept proc used to receive a message  */
  595. typedef OSStatus (*MessageAcceptProc)(const MessageControlBlock *message, void *acceptRefcon);
  596. /*    Version for GetPortInformation  */
  597.  
  598. enum {
  599.     kPortInformationVersion        = 1
  600. };
  601.  
  602. /*  Buffer used to return message port information  */
  603. struct PortInformation {
  604.     KernelProcessID                 owningKernelProcess;
  605.     MessageAcceptProc                 acceptProc;
  606.     ExceptionHandler                 acceptHandler;
  607.     AcceptOptions                     theAcceptOptions;
  608.     void *                            acceptRefcon;
  609.     ItemCount                         objectCount;
  610.     ItemCount                         pendingReceives;
  611.     ItemCount                         pendingSends;
  612.     ItemCount                         pendingReplies;
  613.     ItemCount                         transactionCount;
  614.     ItemCount                         blockedAsyncSenders;
  615.     ItemCount                         blockedAsyncReceivers;
  616. };
  617. typedef struct PortInformation PortInformation;
  618.  
  619. typedef PortInformation *PortInformationPtr;
  620. #endif
  621. #if FOR_SYSTEM7_AND_SYSTEM8_PREEMPTIVE
  622. /*  Tasks  */
  623. extern ExecutionLevel CurrentExecutionLevel(void );
  624.  
  625. extern TaskID CurrentTaskID(void );
  626.  
  627. extern OSStatus DelayFor(Duration delayDuration);
  628.  
  629. extern Boolean InPrivilegedMode(void );
  630.  
  631. /*  Software Interrupts  */
  632. extern OSStatus CreateSoftwareInterrupt(SoftwareInterruptHandler handler, TaskID task, void *p1, Boolean persistent, SoftwareInterruptID *theSoftwareInterrupt);
  633.  
  634. extern OSStatus SendSoftwareInterrupt(SoftwareInterruptID theSoftwareInterrupt, void *p2);
  635.  
  636. extern OSStatus DeleteSoftwareInterrupt(SoftwareInterruptID theSoftwareInterrupt);
  637.  
  638. extern void DisableSoftwareInterrupts(void );
  639.  
  640. extern void EnableSoftwareInterrupts(void );
  641.  
  642. extern Boolean InSoftwareInterruptHandler(void );
  643.  
  644. /*  Completion Routines  */
  645. extern void DisableCompletionRoutines(void );
  646.  
  647. extern void EnableCompletionRoutines(void );
  648.  
  649. /*  Secondary Interrupts  */
  650. extern OSStatus CallSecondaryInterruptHandler2(SecondaryInterruptHandler2 theHandler, ExceptionHandler exceptionHandler, void *p1, void *p2);
  651.  
  652. extern OSStatus QueueSecondaryInterruptHandler(SecondaryInterruptHandler2 theHandler, ExceptionHandler exceptionHandler, void *p1, void *p2);
  653.  
  654. /*  Timers  */
  655. extern OSStatus SetInterruptTimer(const AbsoluteTime *expirationTime, SecondaryInterruptHandler2 handler, void *p1, TimerID *theTimer);
  656.  
  657. extern OSStatus CancelTimer(TimerID theTimer, AbsoluteTime *timeRemaining);
  658.  
  659. /*  IO related Operations  */
  660. extern OSStatus PrepareMemoryForIO(IOPreparationTable *theIOPreparationTable);
  661.  
  662. extern OSStatus CheckpointIO(IOPreparationID theIOPreparation, IOCheckpointOptions options);
  663.  
  664. /*  Memory Operations  */
  665. extern OSStatus GetPageInformation(AddressSpaceID addressSpace, ConstLogicalAddress base, ItemCount requestedPages, PBVersion version, PageInformation *thePageInfo);
  666.  
  667. /*  Processor Cache Related  */
  668. extern OSStatus SetProcessorCacheMode(AddressSpaceID addressSpace, ConstLogicalAddress base, ByteCount length, ProcessorCacheMode cacheMode);
  669.  
  670. #endif
  671. #if FOR_SYSTEM8_PREEMPTIVE
  672. /*  Queues  */
  673. extern OSStatus CreateKernelQueue(KernelQueueOptions options, KernelQueueID *theQueue);
  674.  
  675. extern OSStatus DeleteKernelQueue(KernelQueueID theQueue);
  676.  
  677. extern OSStatus WaitOnKernelQueue(KernelQueueID theQueue, void **p1, void **p2, void **p3, Duration timeOut);
  678.  
  679. extern OSStatus NotifyKernelQueue(KernelQueueID theQueue, void *p1, void *p2, void *p3);
  680.  
  681. extern OSStatus AdjustKernelQueueSIHLimit(KernelQueueID theQueue, SInt32 amount, ItemCount *newLimit);
  682.  
  683. /*  Event Flag Related Operations  */
  684. extern OSStatus CreateEventGroup(EventGroupID *theGroup);
  685.  
  686. extern OSStatus DeleteEventGroup(EventGroupID theGroup);
  687.  
  688. extern OSStatus SetEvents(EventGroupID theGroup, EventGroupMask mask);
  689.  
  690. extern OSStatus ClearEvents(EventGroupID theGroup, EventGroupMask mask);
  691.  
  692. extern OSStatus ReadEvents(EventGroupID theGroup, EventGroupMask *currentValue);
  693.  
  694. extern OSStatus WaitForEvents(EventGroupID theGroup, Duration timeOut, EventGroupMask mask, EventFlagOperation operation, EventGroupMask *value);
  695.  
  696. /*  KernelProcess Related Operations  */
  697. extern OSStatus CreateKernelProcess(KernelProcessName name, AddressSpaceID addressSpace, KernelProcessOptions options, KernelProcessID *theKernelProcess);
  698.  
  699. extern OSStatus ExitKernelProcess(TerminateOptions options, OSStatus exitStatus);
  700.  
  701. extern OSStatus DeleteKernelProcess(KernelProcessID theKernelProcess, TerminateOptions options, OSStatus deleteStatus);
  702.  
  703. extern OSStatus GetKernelProcessesInSystem(ItemCount requestedKernelProcesses, ItemCount *totalKernelProcesses, KernelProcessID *theKernelProcesses);
  704.  
  705. extern OSStatus GetKernelProcessInformation(KernelProcessID theKernelProcess, PBVersion version, KernelProcessInformation *kernelProcessInfo);
  706.  
  707. extern KernelProcessID CurrentKernelProcessID(void );
  708.  
  709. /*  Task Related Operations  */
  710. extern OSStatus CreateTask(TaskName name, KernelProcessID owningKernelProcess, TaskProc entryPoint, void *parameter, LogicalAddress stackBase, ByteCount stackSize, const KernelNotification *notification, TaskOptions options, TaskID *theTask);
  711.  
  712. extern OSStatus ExitTask(TerminateOptions options, OSStatus exitStatus);
  713.  
  714. extern OSStatus TerminateTask(TaskID theTask, TaskRelationship scope, TerminateOptions options, OSStatus terminateStatus);
  715.  
  716. extern ByteCount RemainingStackSpace(void );
  717.  
  718. extern OSStatus GetTaskInformation(TaskID theTask, PBVersion version, TaskInformation *taskInfo);
  719.  
  720. extern OSStatus SetTaskPriority(TaskID theTask, TaskRelationship scope, SetTaskPriorityOptions options);
  721.  
  722. extern OSStatus GetTasksInKernelProcess(KernelProcessID kernelProcess, ItemCount requestedTasks, ItemCount *totalTasks, TaskID *theTasks);
  723.  
  724. extern OSStatus AllocateTaskStorageIndex(TaskStorageIndex *theIndex);
  725.  
  726. extern OSStatus DeallocateTaskStorageIndex(TaskStorageIndex theIndex);
  727.  
  728. extern OSStatus SetTaskStorageValue(TaskStorageIndex theIndex, TaskStorageValue newValue);
  729.  
  730. extern TaskStorageValue GetTaskStorageValue(TaskStorageIndex theIndex);
  731.  
  732. /* Secondary Interrupt Handlers */
  733. extern OSStatus AdjustSecondaryInterruptHandlerLimit(SInt32 amount, ItemCount *newLimit);
  734.  
  735. /*  Timers  */
  736. extern OSStatus DelayUntil(const AbsoluteTime *expirationTime);
  737.  
  738. extern OSStatus SetTimer(const AbsoluteTime *expirationTime, const KernelNotification *notification, TimerOptions options, TimerID *theTimer);
  739.  
  740. extern OSStatus ResetTimer(TimerID theTimer, const AbsoluteTime *expirationTime, const KernelNotification *notification, TimerOptions options);
  741.  
  742. extern OSStatus AdjustInterruptTimerSIHLimit(SInt32 amount, ItemCount *newLimit);
  743.  
  744. /*  Address Space Management  */
  745. extern OSStatus CreateAddressSpace(AddressSpaceID *theAddressSpace);
  746.  
  747. extern OSStatus DeleteAddressSpace(AddressSpaceID theAddressSpace);
  748.  
  749. extern OSStatus GetAddressSpacesInSystem(ItemCount requestedAddressSpaces, ItemCount *totalAddressSpaces, AddressSpaceID *theAddressSpaces);
  750.  
  751. extern OSStatus GetSpaceInformation(AddressSpaceID theAddressSpace, PBVersion version, SpaceInformation *spaceInfo);
  752.  
  753. extern OSStatus InterspaceBlockCopy(AddressSpaceID sourceAddressSpace, AddressSpaceID targetAddressSpace, ConstLogicalAddress sourceBase, LogicalAddress targetBase, ByteCount length, InterspaceCopyOptions options);
  754.  
  755. extern OSStatus CheckUserAccess(ConstLogicalAddress address, ByteCount length, MemoryReferenceKind referenceKind);
  756.  
  757. extern AddressSpaceID CurrentAddressSpaceID(void );
  758.  
  759. /*  Area Management  */
  760. extern OSStatus CreateArea(KernelProcessID owningKernelProcess, BackingObjectID backingObject, const BackingAddress *backingBase, ByteCount backingLength, MemoryAccessLevel userAccessLevel, MemoryAccessLevel privilegedAccessLevel, ByteCount guardLength, AreaOptions options, LogicalAddress *areaBase, AreaID *theArea);
  761.  
  762. extern OSStatus CreateAreaForRange(KernelProcessID owningKernelProcess, AddressSpaceID otherSpace, ConstLogicalAddress otherBase, ByteCount length, MemoryAccessLevel userAccessLevel, MemoryAccessLevel privilegedAccessLevel, ByteCount guardLength, AreaOptions options, LogicalAddress *areaBase, AreaID *theArea);
  763.  
  764. extern OSStatus DeleteArea(AreaID theArea);
  765.  
  766. extern OSStatus GetAreaInformation(AreaID theArea, PBVersion version, AreaInformation *areaInfo);
  767.  
  768. extern OSStatus GetAreaFromAddress(AddressSpaceID addressSpace, ConstLogicalAddress address, AreaID *theArea);
  769.  
  770. extern OSStatus GetAreasInAddressSpace(AddressSpaceID addressSpace, ItemCount requestedAreas, ItemCount *totalAreas, AreaID *theAreas);
  771.  
  772. extern OSStatus SetAreaAccess(AreaID theArea, MemoryAccessLevel userAccessLevel, MemoryAccessLevel privilegedAccessLevel);
  773.  
  774. extern OSStatus SetAreaBackingBase(AreaID theArea, const BackingAddress *backingBase);
  775.  
  776. extern OSStatus CreateAreaReservation(KernelProcessID owningKernelProcess, LogicalAddress *reservationBase, ByteCount length, ReservationOptions options, AreaReservationID *theReservation);
  777.  
  778. extern OSStatus DeleteAreaReservation(AreaReservationID theReservation);
  779.  
  780. extern OSStatus GetReservationInformation(AreaReservationID theReservation, PBVersion version, ReservationInformation *reservationInfo);
  781.  
  782. extern OSStatus GetReservationsInAddressSpace(AddressSpaceID addressSpace, ItemCount requestedReservations, ItemCount *totalReservations, AreaReservationID *theReservations);
  783.  
  784. /*  Processor Cache Related  */
  785. extern OSStatus DataToCode(AddressSpaceID addressSpace, ConstLogicalAddress base, ByteCount length);
  786.  
  787. extern OSStatus FlushRange(AddressSpaceID addressSpace, ConstLogicalAddress base, ByteCount length);
  788.  
  789. /*  Paging control operations  */
  790. extern OSStatus ControlPagingForRange(AddressSpaceID addressSpace, ConstLogicalAddress base, ByteCount length, PageControlOperation operation);
  791.  
  792. extern OSStatus ReleaseData(AddressSpaceID addressSpace, ConstLogicalAddress base, ByteCount length, ReleaseDataOptions options);
  793.  
  794. /*  Message Port Management  */
  795. extern OSStatus CreatePort(PortOptions options, PortID *thePort);
  796.  
  797. extern OSStatus DeletePort(PortID thePort);
  798.  
  799. extern OSStatus GetPortInformation(PortID thePort, PBVersion version, PortInformation *portInfo);
  800.  
  801. extern OSStatus GetPortsInSystem(ItemCount requestedPorts, ItemCount *totalPorts, PortID *thePorts);
  802.  
  803. /*  Message Object Management  */
  804. extern OSStatus CreateObject(PortID port, void *refcon, ObjectOptions options, ObjectID *theObject);
  805.  
  806. extern OSStatus DeleteObject(ObjectID theObject);
  807.  
  808. extern OSStatus LockObject(ObjectID theObject, ObjectLockOptions options, Duration timeOut);
  809.  
  810. extern OSStatus UnlockObject(ObjectID theObject);
  811.  
  812. extern OSStatus GetObjectInformation(ObjectID theObject, PortID *port, void **refcon);
  813.  
  814. extern OSStatus SetObjectInformation(ObjectID theObject, SetObjectOptions options, PortID port, void *refcon);
  815.  
  816. extern OSStatus GetObjectsInPort(PortID port, ItemCount requestedObjects, ItemCount *totalObjects, ObjectID *theObjects);
  817.  
  818. /*  Message Transaction Operations  */
  819. extern OSStatus SendMessageSync(ObjectID object, MessageType theType, ConstLogicalAddress messageContents, ByteCount messageContentsSize, LogicalAddress replyBuffer, ByteCount *replyBufferSize, SendOptions options, Duration timeOut);
  820.  
  821. extern OSStatus SendMessageAsync(ObjectID object, MessageType theType, ConstLogicalAddress messageContents, ByteCount messageContentsSize, LogicalAddress replyBuffer, ByteCount replyBufferSize, SendOptions options, const KernelNotification *notification, ByteCount *replySize, MessageID *theMessage);
  822.  
  823. extern OSStatus AcceptMessage(PortID port, MessageType theTypes, MessageAcceptProc acceptProc, ExceptionHandler theExceptionHandler, AcceptOptions options, void *acceptRefcon);
  824.  
  825. extern OSStatus ReceiveMessageSync(PortID port, MessageType theTypes, MessageControlBlock *theControlBlock, LogicalAddress buffer, ByteCount bufferSize, ReceiveOptions options, Duration timeOut);
  826.  
  827. extern OSStatus ReceiveMessageAsync(PortID port, MessageType theTypes, MessageControlBlock *theControlBlock, LogicalAddress buffer, ByteCount bufferSize, ReceiveOptions options, const KernelNotification *notification, ReceiveID *theReceive);
  828.  
  829. extern OSStatus ReplyToMessage(MessageID theMessage, OSStatus status, ConstLogicalAddress replyBuffer, ByteCount replyBufferSize);
  830.  
  831. extern OSStatus ReplyToMessageAndReceive(MessageID theMessage, OSStatus status, ConstLogicalAddress replyBuffer, ByteCount replyBufferSize, PortID port, MessageType theTypes, MessageControlBlock *theControlBlock, LogicalAddress receiveBuffer, ByteCount receiveBufferSize, ReceiveOptions options, Duration timeOut);
  832.  
  833. /*  Miscellaneous Messaging operations  */
  834. extern OSStatus CancelAsyncSend(MessageID theMessage);
  835.  
  836. extern OSStatus CancelAsyncReceive(ReceiveID theReceive);
  837.  
  838. extern OSStatus GetMessageInformation(MessageID theMessage, PBVersion version, MessageInformation *messageInfo);
  839.  
  840. /*  Miscellaneous System operations  */
  841. extern OSStatus GetSystemInformation(PBVersion version, SystemInformation *systemInfo);
  842.  
  843. /*    Notifications  */
  844. extern OSStatus DeliverKernelNotification(const KernelNotification *notification, OSStatus status);
  845.  
  846. #endif
  847. #if FOR_SYSTEM8_PREEMPTIVE
  848. /* These are defined in Memory for System 7 */
  849. extern pascal void BlockMove(const void *srcPtr, void *destPtr, long byteCount);
  850.  
  851. extern pascal void BlockMoveData(const void *srcPtr, void *destPtr, long byteCount);
  852.  
  853. extern void BlockMoveUncached(const void *srcPtr, void *destPtr, long byteCount);
  854.  
  855. extern void BlockMoveDataUncached(const void *srcPtr, void *destPtr, long byteCount);
  856.  
  857. extern void BlockZero(void *destPtr, long byteCount);
  858.  
  859. extern void BlockZeroUncached(void *destPtr, long byteCount);
  860.  
  861. #endif
  862.  
  863. #pragma options align=reset
  864. #endif /* PRAGMA_ALIGN_SUPPORTED */
  865.  
  866. #if PRAGMA_IMPORT_SUPPORTED
  867. #pragma import off
  868. #endif
  869.  
  870. #ifdef __cplusplus
  871. }
  872. #endif
  873.  
  874. #endif /* __KERNEL__ */
  875.  
  876.